package com.bdqn.Practice.service;

import com.bdqn.Practice.mapper.SysUserMapper;
import com.bdqn.Practice.pojo.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import javax.annotation.Resources;
import java.util.List;

@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService{
    @Autowired
    private SysUserMapper userMapper;

    @Override
    public int updateAll(SysUser sysUser) {
        return userMapper.updateAll(sysUser);
    }

    @Override
    public SysUser selectAll(Integer id) {
        return userMapper.selectAll(id);
    }
    
    @Override
    public SysUser userList(String account, String password) {
        if (account==null && account==""){
            return null;
        }
        if (password==null&&password==""){
            return null;
        }
        if (!userMapper.userList(account).getPassword().equals(password)){
            return null;
        }
        return userMapper.userList(account);
    }

    @Override
    public List<SysUser> List(String realName, Integer roleId, Integer pageNo, Integer pageSize) {
        return userMapper.List(realName,roleId,(pageNo-1)*pageSize,pageSize);
    }

    @Override
    public int count(String realName, Integer roleId) {
        return userMapper.count(realName,roleId);
    }

    @Override
    public int addUser(SysUser sysUser) {
        return userMapper.addUser(sysUser);
    }

    @Override
    public int getByCount(String name) {
        return userMapper.getByCount(name);
    }


}
